package com.sbs.gaoxinqutoilet.fragment;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.ListPopupWindow;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;

import com.bumptech.glide.Glide;
import com.google.gson.reflect.TypeToken;
import com.lvfq.pickerview.TimePickerView;
import com.sbs.gaoxinqutoilet.R;
import com.sbs.gaoxinqutoilet.activity.AccepterActivity;
import com.sbs.gaoxinqutoilet.base.BaseBackFragment;
import com.sbs.gaoxinqutoilet.entity.AcceptDetialEntity;
import com.sbs.gaoxinqutoilet.entity.AcceptImageEntity;
import com.sbs.gaoxinqutoilet.entity.AcceptItemEntity;
import com.sbs.gaoxinqutoilet.entity.AcceptanceEntity;
import com.sbs.gaoxinqutoilet.entity.FIleEditSaveUpEntity;
import com.sbs.gaoxinqutoilet.entity.MessageEvent;
import com.sbs.gaoxinqutoilet.entity.UploadImageEntity;
import com.sbs.gaoxinqutoilet.eventbus.EventCenter;
import com.sbs.gaoxinqutoilet.eventbus.StartNewFragmentEvent;
import com.sbs.gaoxinqutoilet.http.HttpApis;
import com.sbs.gaoxinqutoilet.http.Request;
import com.sbs.gaoxinqutoilet.interfaces.Constants;
import com.sbs.gaoxinqutoilet.interfaces.DialogClick;
import com.sbs.gaoxinqutoilet.interfaces.EventConstant;
import com.sbs.gaoxinqutoilet.interfaces.PopuClickListener;
import com.sbs.gaoxinqutoilet.myapp.MyApplication;
import com.sbs.gaoxinqutoilet.utils.GsonTools;
import com.sbs.gaoxinqutoilet.utils.HttpUtils;
import com.sbs.gaoxinqutoilet.utils.ImageLoaderUtils;
import com.sbs.gaoxinqutoilet.utils.ImageUtils;
import com.sbs.gaoxinqutoilet.utils.JsonUtil;
import com.sbs.gaoxinqutoilet.utils.LogUtils;
import com.sbs.gaoxinqutoilet.utils.NetTimeUtils;
import com.sbs.gaoxinqutoilet.utils.SPUtil;
import com.sbs.gaoxinqutoilet.utils.TimeUtils;
import com.sbs.gaoxinqutoilet.utils.Util;
import com.sbs.gaoxinqutoilet.utils.UtilPop;
import com.sbs.gaoxinqutoilet.utils.appinstallerutils.ConstUtils;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;
import com.zhy.http.okhttp.OkHttpUtils;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import me.codeboy.android.aligntextview.CBAlignTextView;
import me.iwf.photopicker.PhotoPicker;
import top.zibin.luban.Luban;


/**
 * Created by 聪明一只哈 on 2018/6/1.
 * Time: 2018/6/1  10:01
 */

public class ToiletAcceptDetialFragment extends BaseBackFragment implements View.OnClickListener {

    //假数据,传过来的值  存储在Bundle中
    private static final String ACCEPTdATA = "acceptdatabean";

    private static final int LAYOUT_ONE = 0;
    private static final int LAYOUT_TWO = 1;
    private static final int LAYOUT_THREE = 2;
    private static final int RESAULTCODESHOW = 360;

    private View view;
    private TextView accept_user_name;
    private TextView accept_user_address;
    private TextView accept_user_pcode;
    private TextView accept_user_tell;
    private TextView accept_user_tellD;
    private TextView accept_user_IDLE;
    private TextView accept_user_state;
    private TextView accept_user_type;
    private TextView accept_buildstyle;
    private TextView accept_detuser_year;
    private TextView accept_user_shigongteam;
    private TextView accept_user_huafenchi;
    private RadioButton rb_one_pass;
    private RadioButton rb_one_fail;
    private RadioButton rb_two_pass;
    private RadioButton rb_two_fail;
    private RadioButton rb_three_pass;
    private RadioButton rb_three_fail;
    private RadioButton rb_four_pass;
    private RadioButton rb_four_fail;
    private RadioButton rb_five_pass;
    private RadioButton rb_five_fail;
    private TextView tv_pull_choice;
    private TextView tv_acceptance;
    private TextView tv_date_pickter;
    private EditText et_filereason;
    private Button bt_save;
    private Toolbar toolbar;
    private ScrollView applyBuySv;
    private ImageView toolbarBack;
    private TextView toolbarTitle;
    private LinearLayout accept_user_showbody;
    private RelativeLayout accept_detuser_title;
    private ImageView accept_detuser_iv_arrow;

    //验收结果
    private ListPopupWindow accept_resault_popupWindow;
    List<String> accept_resaultlist = new ArrayList<>();

    private TimePickerView pvTime;
    private RadioGroup rg_question_one;
    private RadioGroup rg_question_two;
    private RadioGroup rg_question_three;
    private RadioGroup rg_question_four;
    private RadioGroup rg_question_five;

    //存储参数的集合
    private Map<String, Object> qrbparams = new HashMap<>();
    //传过来的数据
    private AcceptItemEntity.DataBean acceptdatabean;
    private AcceptDetialRequest acceptDelrequest;
    private ImageView accept_image_a;
    private ImageView accept_image_b;
    private ImageView accept_image_c;
    private ImageView accept_image_d;
    private ImageView accept_image_e;
    private ImageView imag_acceptdetail_gaizaotwo;
    private ImageView imag_acceptdetail_gaizaothree;
    private ArrayList<AcceptImageEntity> acceptImageEntities;
    private ArrayList<AcceptImageEntity> acceptImageEntitiesGaizao;
    private CBAlignTextView rebuild_date;
    private CBAlignTextView rebuild_buildtype;
    private CBAlignTextView rebuild_sgd;
    private ImageView rebuild_image_ing;
    private ImageView rebuild_image_after;
    private ImageView accept_rebuild_other_two;
    private ImageView accept_rebuild_other_three;
    private AutoRelativeLayout accept_rebuild_title;
    private ImageView accept_rebuild_arrow;
    private AutoLinearLayout accept_rebuild_body;
    private RadioGroup rg_question_six;
    private RadioGroup rg_question_seven;
    private RadioGroup rg_question_eight;
    private RadioGroup rg_question_nine;
    private RadioGroup rg_question_ten;
    private RadioGroup rg_question_eleven;
    private RadioGroup rg_question_twelve;
    private RadioGroup rg_question_thirdteen;
    private RadioGroup rg_question_fourteen;
    private RadioGroup rg_question_fifteen;
    private RadioGroup rg_question_sixteen;
    private RadioGroup rg_question_seventeen;
    private RadioButton rb_six_pass;
    private RadioButton rb_six_fail;
    private RadioButton rb_seven_pass;
    private RadioButton rb_seven_fail;
    private RadioButton rb_eight_pass;
    private RadioButton rb_eight_fail;
    private RadioButton rb_nine_pass;
    private RadioButton rb_nine_fail;
    private RadioButton rb_ten_pass;
    private RadioButton rb_ten_fail;
    private RadioButton rb_eleven_pass;
    private RadioButton rb_eleven_fail;
    private RadioButton rb_twelve_pass;
    private RadioButton rb_twelve_fail;
    private RadioButton rb_thirdteen_pass;
    private RadioButton rb_thirdteen_fail;
    private RadioButton rb_fouthteen_pass;
    private RadioButton rb_fouthteen_fail;
    private RadioButton rb_fifteen_pass;
    private RadioButton rb_fifteen_fail;
    private RadioButton rb_sixteen_pass;
    private RadioButton rb_sixteen_fail;
    private RadioButton rb_seventeen_pass;
    private RadioButton rb_seventeen_fail;
    private TextView acceptRenkouTrascode;
    private TextView acceptTelTrascode;
    private TextView accept_bianchi;
    private TextView accept_chongshui;
    private TextView accept_cefang;
    private RadioGroup rg_question_five_half;
    private RadioButton rb_five_half_pass;
    private RadioButton rb_five_half_fail;
    private TextView upimg_statue;
    private RelativeLayout up_accept_rl_a;
    private RelativeLayout up_accept_rl_b;
    private RelativeLayout up_accept_xiang;
    private RelativeLayout up_accept_xian;
    private RelativeLayout up_accept_shi;
    private ImageView sell_accept_one;
    private ImageView sell_accept_two;
    private ImageView accept_myFile_three;
    private ImageView accept_myFile_four;
    private ImageView accept_myFile_five;
    private ImageView image_accept_a;
    private ImageView image_accept_b;
    private ImageView image_accept_xiang;
    private ImageView image_accept_xian;
    private ImageView image_accept_shi;
    private AcceptDetialEntity acceptDetialentity;
    private LinearLayout all_accept_det_unfail;
    private View view_a;
    private String optLevel;
    private String netTime;
    private TextView tv_accept_imga;
    private TextView tv_accept_imgb;
    private TextView tv_accept_imgc;
    private TextView tv_accept_imgd;
    private TextView tv_accept_imge;
    private TextView tv_acceptdetail_gaizaotwo;
    private TextView tv_acceptdetail_gaizaothree;
    private String token_data;

    public static ToiletAcceptDetialFragment newInstance(AcceptItemEntity.DataBean dataBean) {//AcceptItemEntity.DataBean

        Bundle args = new Bundle();
        args.putSerializable(ACCEPTdATA, dataBean);
        ToiletAcceptDetialFragment fragment = new ToiletAcceptDetialFragment();
        fragment.setArguments(args);
        return fragment;
    }

    private Handler handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case LAYOUT_ONE:
                    loadLayoutOne();
                    break;
                case LAYOUT_TWO:
                    loadLayoutTwo();
                    break;
                case LAYOUT_THREE:
                    initView(view);
                    initListener();
                    loadMoreData();
                    break;
                default:

            }
        }
    };

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        view = inflater.inflate(R.layout.fragment_accept_detial, container, false);
        View detialLl = view.findViewById(R.id.buy_apply_ll);

        detialLl.setFocusable(true);
        detialLl.setFocusableInTouchMode(true);
        detialLl.requestFocus();

        return view;
    }

    /**
     * 加载个人信息和问题列表 并初始化
     */
    private void loadLayoutOne() {
        ViewStub infalte_usershow = (ViewStub) view.findViewById(R.id.inflat_question_usershow);
        ViewStub infalte_questionlist = (ViewStub) view.findViewById(R.id.inflat_question_list);
        ViewStub inflat_up_image = (ViewStub) view.findViewById(R.id.inflat_up_image);
        ViewStub inflat_rebuildshow = (ViewStub) view.findViewById(R.id.inflat_question_rebuildshow);


        //个人信息
        View inflate_one = infalte_usershow.inflate();
        accept_user_name = (TextView) inflate_one.findViewById(R.id.accept_detuser_name);
        accept_user_address = (TextView) inflate_one.findViewById(R.id.accept_detuser_address);
        accept_user_pcode = (TextView) inflate_one.findViewById(R.id.accept_detuser_trascode);

        acceptRenkouTrascode = (TextView) inflate_one.findViewById(R.id.accept_renkou_trascode);
        acceptTelTrascode = (TextView) inflate_one.findViewById(R.id.accept_tel_trascode);

        accept_user_tell = (TextView) inflate_one.findViewById(R.id.accept_detuser_tel);
        accept_user_tellD = (TextView) inflate_one.findViewById(R.id.accept_detuser_telb);
        accept_user_IDLE = (TextView) inflate_one.findViewById(R.id.accept_detuser_telc);
        accept_user_state = (TextView) inflate_one.findViewById(R.id.accept_detuser_teld);
        accept_user_type = (TextView) inflate_one.findViewById(R.id.accept_detuser_tele);
        accept_buildstyle = (TextView) inflate_one.findViewById(R.id.accept_buildstyle);
        accept_detuser_year = (TextView) inflate_one.findViewById(R.id.accept_detuser_year);
        accept_user_shigongteam = (TextView) inflate_one.findViewById(R.id.accept_detuser_telf);
        accept_user_huafenchi = (TextView) inflate_one.findViewById(R.id.accept_detuser_telg);
        accept_user_showbody = (LinearLayout) inflate_one.findViewById(R.id.apply_show_body);
        accept_detuser_title = (RelativeLayout) inflate_one.findViewById(R.id.accept_detuser_title);
        accept_detuser_iv_arrow = (ImageView) inflate_one.findViewById(R.id.accept_detuser_iv_arrow);
        accept_image_a = (ImageView) inflate_one.findViewById(R.id.imaga);
        accept_image_b = (ImageView) inflate_one.findViewById(R.id.imagb);
        accept_image_c = (ImageView) inflate_one.findViewById(R.id.imagc);
        accept_image_d = (ImageView) inflate_one.findViewById(R.id.imagd);
        accept_image_e = (ImageView) inflate_one.findViewById(R.id.image);
        imag_acceptdetail_gaizaotwo = (ImageView) inflate_one.findViewById(R.id.imag_acceptdetail_gaizaotwo);
        imag_acceptdetail_gaizaothree = (ImageView) inflate_one.findViewById(R.id.imag_acceptdetail_gaizaothree);

        tv_accept_imga = (TextView) inflate_one.findViewById(R.id.tv_accept_imga);
        tv_accept_imgb = (TextView) inflate_one.findViewById(R.id.tv_accept_imgb);
        tv_accept_imgc = (TextView) inflate_one.findViewById(R.id.tv_accept_imgc);
        tv_accept_imgd = (TextView) inflate_one.findViewById(R.id.tv_accept_imgd);
        tv_accept_imge = (TextView) inflate_one.findViewById(R.id.tv_accept_imge);
        tv_acceptdetail_gaizaotwo = (TextView) inflate_one.findViewById(R.id.tv_acceptdetail_gaizaotwo);
        tv_acceptdetail_gaizaothree = (TextView) inflate_one.findViewById(R.id.tv_acceptdetail_gaizaothree);

        accept_bianchi = (TextView) inflate_one.findViewById(R.id.accept_bianchi_telg);
        accept_chongshui = (TextView) inflate_one.findViewById(R.id.accept_chongshui_telg);
        accept_cefang = (TextView) inflate_one.findViewById(R.id.accept_cefang_telg);


        //重建信息
        View inflate_one_half = inflat_rebuildshow.inflate();
        accept_rebuild_title = (AutoRelativeLayout) inflate_one_half.findViewById(R.id.accept_rebuild_iner_title);
        accept_rebuild_body = (AutoLinearLayout) inflate_one_half.findViewById(R.id.accept_rebuild_iner_show_body);
        accept_rebuild_arrow = (ImageView) inflate_one_half.findViewById(R.id.accept_rebuild_iner_iv_arrow);
        rebuild_date = (CBAlignTextView) inflate_one_half.findViewById(R.id.accept_rebuild_iner_date);
        rebuild_buildtype = (CBAlignTextView) inflate_one_half.findViewById(R.id.accept_rebuild_iner_buildtype);
        rebuild_sgd = (CBAlignTextView) inflate_one_half.findViewById(R.id.accept_rebuild_iner_sgd);
        rebuild_image_ing = (ImageView) inflate_one_half.findViewById(R.id.accept_rebuild_iner_ing);
        rebuild_image_after = (ImageView) inflate_one_half.findViewById(R.id.accept_rebuild_iner_after);
        accept_rebuild_other_two = (ImageView) inflate_one_half.findViewById(R.id.accept_rebuild_other_two);
        accept_rebuild_other_three = (ImageView) inflate_one_half.findViewById(R.id.accept_rebuild_other_three);


        //问题列表
        View inflate_two = infalte_questionlist.inflate();

        //RG
        rg_question_one = (RadioGroup) inflate_two.findViewById(R.id.rg_question_one);
        rg_question_two = (RadioGroup) inflate_two.findViewById(R.id.rg_question_two);
        rg_question_three = (RadioGroup) inflate_two.findViewById(R.id.rg_question_three);
        rg_question_four = (RadioGroup) inflate_two.findViewById(R.id.rg_question_four);
        rg_question_five = (RadioGroup) inflate_two.findViewById(R.id.rg_question_five);

        rg_question_five_half = (RadioGroup) inflate_two.findViewById(R.id.rg_question_five_half);
        rg_question_six = (RadioGroup) inflate_two.findViewById(R.id.rg_question_six);
        rg_question_seven = (RadioGroup) inflate_two.findViewById(R.id.rg_question_seven);
        rg_question_eight = (RadioGroup) inflate_two.findViewById(R.id.rg_question_eight);
        rg_question_nine = (RadioGroup) inflate_two.findViewById(R.id.rg_question_nine);
        rg_question_ten = (RadioGroup) inflate_two.findViewById(R.id.rg_question_ten);
        rg_question_eleven = (RadioGroup) inflate_two.findViewById(R.id.rg_question_eleven);
        rg_question_twelve = (RadioGroup) inflate_two.findViewById(R.id.rg_question_twelve);
        rg_question_thirdteen = (RadioGroup) inflate_two.findViewById(R.id.rg_question_thirdteen);
        rg_question_fourteen = (RadioGroup) inflate_two.findViewById(R.id.rg_question_fouthteen);
        rg_question_fifteen = (RadioGroup) inflate_two.findViewById(R.id.rg_question_fifteen);
        rg_question_sixteen = (RadioGroup) inflate_two.findViewById(R.id.rg_question_sixteen);
        rg_question_seventeen = (RadioGroup) inflate_two.findViewById(R.id.rg_question_seventeen);


        //RB
        rb_one_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_one_pass);
        rb_one_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_one_fail);

        rb_two_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_two_pass);
        rb_two_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_two_fail);

        rb_three_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_three_pass);
        rb_three_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_three_fail);

        rb_four_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_four_pass);
        rb_four_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_four_fail);

        rb_five_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_five_pass);
        rb_five_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_five_fail);

        rb_five_half_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_five_half_pass);
        rb_five_half_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_five_half_fail);
        rb_six_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_six_pass);
        rb_six_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_six_fail);
        rb_seven_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_seven_pass);
        rb_seven_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_seven_fail);
        rb_eight_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_eight_pass);
        rb_eight_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_eight_fail);
        rb_nine_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_nine_pass);
        rb_nine_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_nine_fail);
        rb_ten_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_ten_pass);
        rb_ten_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_ten_fail);
        rb_eleven_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_eleven_pass);
        rb_eleven_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_eleven_fail);
        rb_twelve_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_twelve_pass);
        rb_twelve_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_twelve_fail);
        rb_thirdteen_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_thirdteen_pass);
        rb_thirdteen_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_thirdteen_fail);
        rb_fouthteen_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_fouthteen_pass);
        rb_fouthteen_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_fouthteen_fail);
        rb_fifteen_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_fifteen_pass);
        rb_fifteen_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_fifteen_fail);
        rb_sixteen_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_sixteen_pass);
        rb_sixteen_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_sixteen_fail);
        rb_seventeen_pass = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_seventeen_pass);
        rb_seventeen_fail = (RadioButton) inflate_two.findViewById(R.id.accept_detrb_seventeen_fail);

        //上传文件列表
        View inflate_three = inflat_up_image.inflate();
        upimg_statue = (TextView) inflate_three.findViewById(R.id.tv_upimg_statue);
        up_accept_rl_a = (RelativeLayout) inflate_three.findViewById(R.id.up_accept_rl_a);
        up_accept_rl_b = (RelativeLayout) inflate_three.findViewById(R.id.up_accept_rl_b);
        up_accept_xiang = (RelativeLayout) inflate_three.findViewById(R.id.up_accept_xiang);
        up_accept_xian = (RelativeLayout) inflate_three.findViewById(R.id.up_accept_xian);
        up_accept_shi = (RelativeLayout) inflate_three.findViewById(R.id.up_accept_shi);
        sell_accept_one = (ImageView) inflate_three.findViewById(R.id.sell_accept_one);
        sell_accept_two = (ImageView) inflate_three.findViewById(R.id.sell_accept_two);
        accept_myFile_three = (ImageView) inflate_three.findViewById(R.id.accept_myFile_three);
        accept_myFile_four = (ImageView) inflate_three.findViewById(R.id.accept_myFile_four);
        accept_myFile_five = (ImageView) inflate_three.findViewById(R.id.accept_myFile_five);
        image_accept_a = (ImageView) inflate_three.findViewById(R.id.image_accept_a);
        image_accept_b = (ImageView) inflate_three.findViewById(R.id.image_accept_b);
        image_accept_xiang = (ImageView) inflate_three.findViewById(R.id.image_accept_xiang);
        image_accept_xian = (ImageView) inflate_three.findViewById(R.id.image_accept_xian);
        image_accept_shi = (ImageView) inflate_three.findViewById(R.id.image_accept_shi);


    }

    /**
     * 加载余下的布局 并初始化
     */
    private void loadLayoutTwo() {
        ViewStub infalte_rest = (ViewStub) view.findViewById(R.id.inflat_rest);
        View inflate_rest_show = infalte_rest.inflate();
        tv_pull_choice = (TextView) inflate_rest_show.findViewById(R.id.accept_det_tv_pull_choices);
        tv_acceptance = (TextView) inflate_rest_show.findViewById(R.id.accept_det_tv_acceptance);
        tv_date_pickter = (TextView) inflate_rest_show.findViewById(R.id.accept_det_tv_date);
        et_filereason = (EditText) inflate_rest_show.findViewById(R.id.accept_tv_fail_reasuon);
        all_accept_det_unfail = (LinearLayout) inflate_rest_show.findViewById(R.id.all_accept_det_unfail);
        view_a = (View) inflate_rest_show.findViewById(R.id.view_a);
        bt_save = (Button) inflate_rest_show.findViewById(R.id.accept_det_bt_save);

    }

    /**
     * 动画结束后执行
     * 通过handler加载布局
     *
     * @param savedInstanceState
     */
    @Override
    public void onEnterAnimationEnd(Bundle savedInstanceState) {
        super.onEnterAnimationEnd(savedInstanceState);
        showLoadingDialog("正在加载....");


        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_ONE);
            }
        }, 200);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_TWO);
            }
        }, 600);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_THREE);
            }
        }, 1200);
    }

    /**
     * 初始化公用布局,如:toolbar  scrollview
     *
     * @param view
     */
    private void initView(View view) {
        EventBus.getDefault().register(this);

        token_data = SPUtil.getString(Constants.KEY_TOKEN, "");

        //toolbar初始化
        applyBuySv = (ScrollView) view.findViewById(R.id.my_jescrollview);
        toolbarBack = (ImageView) view.findViewById(R.id.toolbar_back);
        toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
        toolbar = (Toolbar) view.findViewById(R.id.toolbar);
        toolbarTitle.setText("户厕改造验收");
        //返回箭头
        toolbarBack.setVisibility(View.VISIBLE);
        //返回箭头功能 同步
        initToolbarBack(toolbar);
        //时间选择器设置默认时间为当前时间
        //tv_date_pickter.setText("" + getNowTime());

//=====================获取传递过来的值=====================================
        Bundle arguments = getArguments();
        if (arguments != null) {
            acceptdatabean = (AcceptItemEntity.DataBean) arguments.getSerializable(ACCEPTdATA);

            optLevel = acceptdatabean.getLevel();
            boolean edit = acceptdatabean.isEdit();
            LogUtils.i("跳转接受过来的数据", "initView: " + edit);

            //false,不可编辑  true 可编辑
            if (!edit) {
                //rb不可点击

                rb_one_pass.setClickable(false);
                rb_one_fail.setClickable(false);
                rb_two_pass.setClickable(false);
                rb_two_fail.setClickable(false);
                rb_three_pass.setClickable(false);
                rb_three_fail.setClickable(false);
                rb_four_pass.setClickable(false);
                rb_four_fail.setClickable(false);
                rb_five_pass.setClickable(false);
                rb_five_fail.setClickable(false);

                rb_five_half_pass.setClickable(false);
                rb_five_half_fail.setClickable(false);
                rb_six_pass.setClickable(false);
                rb_six_fail.setClickable(false);
                rb_seven_pass.setClickable(false);
                rb_seven_fail.setClickable(false);
                rb_eight_pass.setClickable(false);
                rb_eight_fail.setClickable(false);
                rb_nine_pass.setClickable(false);
                rb_nine_fail.setClickable(false);
                rb_ten_pass.setClickable(false);
                rb_ten_fail.setClickable(false);
                rb_eleven_pass.setClickable(false);
                rb_eleven_fail.setClickable(false);
                rb_twelve_pass.setClickable(false);
                rb_twelve_fail.setClickable(false);
                rb_thirdteen_pass.setClickable(false);
                rb_thirdteen_fail.setClickable(false);
                rb_fouthteen_pass.setClickable(false);
                rb_fouthteen_fail.setClickable(false);
                rb_fifteen_pass.setClickable(false);
                rb_fifteen_fail.setClickable(false);
                rb_sixteen_pass.setClickable(false);
                rb_sixteen_fail.setClickable(false);
                rb_seventeen_pass.setClickable(false);
                rb_seventeen_fail.setClickable(false);

                //验收结果,验收人,验收日期,保存按钮
                tv_pull_choice.setEnabled(false);
                tv_acceptance.setEnabled(false);
                tv_date_pickter.setEnabled(false);

                et_filereason.setEnabled(false);
                et_filereason.setFocusable(false);

                bt_save.setClickable(false);
                bt_save.setEnabled(false);
                bt_save.setBackgroundResource(R.drawable.toilet_sliding_tv_unselected);

            }
        }
//=======================================================================

        getNetTimeNow();
    }

    private void getNetTimeNow() {
        new Thread(){
            @Override
            public void run() {
                netTime = NetTimeUtils.getNetTime();
            }
        }.start();
    }

    /**
     * 添加的各种监听
     */
    private void initListener() {
        accept_rebuild_title.setOnClickListener(this);


        accept_detuser_title.setOnClickListener(this);
        tv_pull_choice.setOnClickListener(this);
        tv_acceptance.setOnClickListener(this);
        tv_date_pickter.setOnClickListener(this);
        bt_save.setOnClickListener(this);

        accept_image_a.setOnClickListener(this);
        accept_image_b.setOnClickListener(this);
        accept_image_c.setOnClickListener(this);
        accept_image_d.setOnClickListener(this);
        accept_image_e.setOnClickListener(this);
        imag_acceptdetail_gaizaotwo.setOnClickListener(this);
        imag_acceptdetail_gaizaothree.setOnClickListener(this);

        //rebuild_image_ing   rebuild_image_after
        rebuild_image_ing.setOnClickListener(this);
        rebuild_image_after.setOnClickListener(this);

        //上传图片
        up_accept_rl_a.setOnClickListener(this);
        up_accept_rl_b.setOnClickListener(this);
        up_accept_xiang.setOnClickListener(this);
        up_accept_xian.setOnClickListener(this);
        up_accept_shi.setOnClickListener(this);


    }

    //记录表添加的数据
    private List<AcceptImageEntity> record_list=new ArrayList<>();
    /**
     * 加载验收详情数据
     */
    private void loadMoreData() {
        //加载user信息

        if (acceptdatabean != null) {
            String accept_detial_url = HttpApis.acceptDetial_edit + acceptdatabean.getYanshou_id();
            LogUtils.i("验收详情", "loadMoreData: " + accept_detial_url);
            if (acceptDelrequest == null) {
                acceptDelrequest = new AcceptDetialRequest();
            }

            HashMap<String, String> map = new HashMap<>();
            map.put("token",token_data);

            HttpUtils.requestGet(_mActivity, accept_detial_url,map, acceptDelrequest);

            record_list.clear();

            getAcceptImageData(acceptdatabean.getYanshou_id());



        }

    }

    /**
     * 请求图片数据
     *
     * @param acceptid
     */
    private void getAcceptImageData(String acceptid) {

        final String accept_image_data = HttpApis.acceptDetial_image;//+acceptid

        LogUtils.i("验收图片数据", accept_image_data);
        Map<String, String> params = new TreeMap<>();
        params.put("mid", acceptid);
        params.put("token",token_data);
        LogUtils.i("验收图片数据", acceptid);

        HttpUtils.requestPost(_mActivity, accept_image_data, params, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.i("验收图片数据", jsonStr);

                Type type = new TypeToken<ArrayList<AcceptImageEntity>>() {
                }.getType();

                acceptImageEntities = JsonUtil.json2Collection(jsonStr, type);

                if (acceptImageEntities != null && acceptImageEntities.size() > 0) {
                    for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                        processImageData(acceptiamgedata);
                    }

                }

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                LogUtils.i("验收图片数据", error);
                cancelLoadingDialog();
            }
        });
    }
    private void getAcceptImageDataGaiZao(String acceptid) {

        final String accept_image_data = HttpApis.acceptDetial_image;//+acceptid

        LogUtils.i("验收图片数据", accept_image_data);
        Map<String, String> params = new TreeMap<>();
        params.put("mid", acceptid);
        params.put("token",token_data);
        LogUtils.i("验收图片数据", acceptid);

        HttpUtils.requestPost(_mActivity, accept_image_data, params, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.i("验收图片数据", jsonStr);

                Type type = new TypeToken<ArrayList<AcceptImageEntity>>() {
                }.getType();

                acceptImageEntitiesGaizao = JsonUtil.json2Collection(jsonStr, type);

                if (acceptImageEntitiesGaizao != null && acceptImageEntitiesGaizao.size() > 0) {
                    for (AcceptImageEntity acceptiamgedata : acceptImageEntitiesGaizao) {
                        //processImageData(acceptiamgedata);
                        processImageDataGaiZao(acceptiamgedata);
                    }

                }

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                LogUtils.i("验收图片数据", error);
                cancelLoadingDialog();
            }
        });
    }



    /**
     * 加载图片数据
     *
     * @param acceptiamgedata
     */
    private void processImageData(AcceptImageEntity acceptiamgedata) {
        //switch (acceptiamgedata.getAdjunct_type()) {file_des
//        switch (acceptiamgedata.getFile_des()) {
//            case "改造前"://13
//                ImageLoaderUtils.setImageUrl(accept_image_a.getContext(), acceptiamgedata.getSys_file_name(), accept_image_c);
//                break;
//            case "改造中"://14
//
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_d);
//                break;
//            case "改造后"://15
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_e);
//                break;
//            case "身份证正面"://11
//            case "身份证":
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_a);
//                break;
//            case "大门照"://12
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_b);
//                break;
//            case "重建中"://14
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), rebuild_image_ing);
//                break;
//            case "重建后"://15
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), rebuild_image_after);
//                break;
//            case "验收记录表"://22
//                sell_accept_one.setVisibility(View.GONE);
//                image_accept_a.setVisibility(View.VISIBLE);
//                isRecordlistSuccess=true;
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_a);
//
//                recordlist_ima[0] = acceptiamgedata.getAdjunct_id();
//                recordlist_ima[1] = acceptiamgedata.getSys_file_name();
//                recordlist_ima[2] = "22";//adjunct_type : 据上传图片定
//                recordlist_ima[3] = acceptiamgedata.getFile_type();
//                recordlist_ima[4] = acceptiamgedata.getFile_size();
//                recordlist_ima[5] = "验收记录表";//file_des:据上传图片定 身份证正面\大门照
//                recordlist_ima[6] = acceptiamgedata.getUser_file_name();
//                recordlist_ima[7] = acceptiamgedata.getPicmd5code();
//
//                record_list.add(acceptiamgedata);
//
//                break;
//            case "验收意见"://23
//                sell_accept_two.setVisibility(View.GONE);
//                image_accept_b.setVisibility(View.VISIBLE);
//                isAdviceSuccess=true;
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_b);
//
//                advice_ima[0] = acceptiamgedata.getAdjunct_id();
//                advice_ima[1] = acceptiamgedata.getSys_file_name();
//                advice_ima[2] = "23";//adjunct_type : 据上传图片定
//                advice_ima[3] = acceptiamgedata.getFile_type();
//                advice_ima[4] = acceptiamgedata.getFile_size();
//                advice_ima[5] = "验收意见";//file_des:据上传图片定 身份证正面\大门照
//                advice_ima[6] = acceptiamgedata.getUser_file_name();
//                advice_ima[7] = acceptiamgedata.getPicmd5code();
//
//                record_list.add(acceptiamgedata);
//                break;
//            default:
//
//                break;
//        }

        //============================================
        switch (acceptiamgedata.getAdjunct_type()) {
//            //case "改造前"://13
//            case "13"://
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_c);
//                break;
//           // case "改造中"://14
//            case "14"://14
//
//                if("改造中".equals(acceptiamgedata.getFile_des())){
//                    ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_d);
//                }else{
//                    ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), rebuild_image_ing);
//                }
//
//                break;
//           // case "改造后"://15
//            case "15"://15
//
//                if("改造后".equals(acceptiamgedata.getFile_des())){
//                    ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_e);
//                }else{
//                    ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), rebuild_image_after);
//                }
//
//                break;
////            case "身份证正面"://11
////            case "身份证":
//            case "11":
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_a);
//                break;
//            //case "大门照"://12
//            case "12"://12
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_b);
//                break;
            //case "重建中"://14  16
            case "16"://14  16
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), rebuild_image_ing);
                break;
            //case "重建后"://15  17
            case "17"://15  17
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), rebuild_image_after);
                break;
            //case "验收记录表"://22
            case "22"://22
                sell_accept_one.setVisibility(View.GONE);
                image_accept_a.setVisibility(View.VISIBLE);
                isRecordlistSuccess=true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_a);

                recordlist_ima[0] = acceptiamgedata.getAdjunct_id();
                recordlist_ima[1] = acceptiamgedata.getSys_file_name();
                recordlist_ima[2] = "22";//adjunct_type : 据上传图片定
                recordlist_ima[3] = acceptiamgedata.getFile_type();
                recordlist_ima[4] = acceptiamgedata.getFile_size();
                recordlist_ima[5] = "验收记录表";//file_des:据上传图片定 身份证正面\大门照
                recordlist_ima[6] = acceptiamgedata.getUser_file_name();
                recordlist_ima[7] = acceptiamgedata.getPicmd5code();

                record_list.add(acceptiamgedata);

                break;
            //case "验收意见"://23
            case "23"://23
                sell_accept_two.setVisibility(View.GONE);
                image_accept_b.setVisibility(View.VISIBLE);
                isAdviceSuccess=true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_b);

                advice_ima[0] = acceptiamgedata.getAdjunct_id();
                advice_ima[1] = acceptiamgedata.getSys_file_name();
                advice_ima[2] = "23";//adjunct_type : 据上传图片定
                advice_ima[3] = acceptiamgedata.getFile_type();
                advice_ima[4] = acceptiamgedata.getFile_size();
                advice_ima[5] = "验收意见";//file_des:据上传图片定 身份证正面\大门照
                advice_ima[6] = acceptiamgedata.getUser_file_name();
                advice_ima[7] = acceptiamgedata.getPicmd5code();

                record_list.add(acceptiamgedata);
                break;
            case "31"://23
                accept_myFile_three.setVisibility(View.GONE);
                image_accept_xiang.setVisibility(View.VISIBLE);
                isXiangSuccess=true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_xiang);

                advice_ima_xiang[0] = acceptiamgedata.getAdjunct_id();
                advice_ima_xiang[1] = acceptiamgedata.getSys_file_name();
                advice_ima_xiang[2] = "31";//adjunct_type : 据上传图片定
                advice_ima_xiang[3] = acceptiamgedata.getFile_type();
                advice_ima_xiang[4] = acceptiamgedata.getFile_size();
                advice_ima_xiang[5] = "乡现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_xiang[6] = acceptiamgedata.getUser_file_name();
                advice_ima_xiang[7] = acceptiamgedata.getPicmd5code();

                record_list.add(acceptiamgedata);
                break;
            case "32":
                accept_myFile_four.setVisibility(View.GONE);
                image_accept_xian.setVisibility(View.VISIBLE);
                isXianSuccess=true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_xian);

                advice_ima_xian[0] = acceptiamgedata.getAdjunct_id();
                advice_ima_xian[1] = acceptiamgedata.getSys_file_name();
                advice_ima_xian[2] = "32";//adjunct_type : 据上传图片定
                advice_ima_xian[3] = acceptiamgedata.getFile_type();
                advice_ima_xian[4] = acceptiamgedata.getFile_size();
                advice_ima_xian[5] = "县现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_xian[6] = acceptiamgedata.getUser_file_name();
                advice_ima_xian[7] = acceptiamgedata.getPicmd5code();

                record_list.add(acceptiamgedata);
                break;
            case "33":
                accept_myFile_five.setVisibility(View.GONE);
                image_accept_shi.setVisibility(View.VISIBLE);
                isShiSuccess=true;
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_shi);

                advice_ima_shi[0] = acceptiamgedata.getAdjunct_id();
                advice_ima_shi[1] = acceptiamgedata.getSys_file_name();
                advice_ima_shi[2] = "33";//adjunct_type : 据上传图片定
                advice_ima_shi[3] = acceptiamgedata.getFile_type();
                advice_ima_shi[4] = acceptiamgedata.getFile_size();
                advice_ima_shi[5] = "市现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_shi[6] = acceptiamgedata.getUser_file_name();
                advice_ima_shi[7] = acceptiamgedata.getPicmd5code();

                record_list.add(acceptiamgedata);
                break;
            default:

                break;
        }

    }
    private void processImageDataGaiZao(AcceptImageEntity acceptiamgedata) {

        switch (acceptiamgedata.getAdjunct_type()) {

            case "13"://
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_c);
                tv_accept_imgc.setText(acceptiamgedata.getFile_des());
                break;
            case "1401"://1401
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_d);
                tv_accept_imgd.setText(acceptiamgedata.getFile_des());
                break;
            case "15"://15
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_e);
                tv_accept_imge.setText(acceptiamgedata.getFile_des());
                break;
            case "11":
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_a);
                tv_accept_imga.setText(acceptiamgedata.getFile_des());
                break;
            case "12"://12
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_image_b);
                tv_accept_imgb.setText(acceptiamgedata.getFile_des());
                break;
            case "1402"://改造中2
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), imag_acceptdetail_gaizaotwo);
                tv_acceptdetail_gaizaotwo.setText(acceptiamgedata.getFile_des());
                break;
            case "1403"://改造中3
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), imag_acceptdetail_gaizaothree);
                tv_acceptdetail_gaizaothree.setText(acceptiamgedata.getFile_des());
                break;
            case "1601"://重建中1
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), rebuild_image_ing);
                break;
            case "17"://重建后
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), rebuild_image_after);
                break;
            case "1602"://重建中2
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_rebuild_other_two);
                break;
            case "1603"://重建中3
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), accept_rebuild_other_three);
                break;
//            //case "验收记录表"://22
//            case "22"://22
//                sell_accept_one.setVisibility(View.GONE);
//                image_accept_a.setVisibility(View.VISIBLE);
//                isRecordlistSuccess=true;
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_a);
//
//                recordlist_ima[0] = acceptiamgedata.getAdjunct_id();
//                recordlist_ima[1] = acceptiamgedata.getSys_file_name();
//                recordlist_ima[2] = "22";//adjunct_type : 据上传图片定
//                recordlist_ima[3] = acceptiamgedata.getFile_type();
//                recordlist_ima[4] = acceptiamgedata.getFile_size();
//                recordlist_ima[5] = "验收记录表";//file_des:据上传图片定 身份证正面\大门照
//                recordlist_ima[6] = acceptiamgedata.getUser_file_name();
//                recordlist_ima[7] = acceptiamgedata.getPicmd5code();
//
//                record_list.add(acceptiamgedata);
//
//                break;
//            //case "验收意见"://23
//            case "23"://23
//                sell_accept_two.setVisibility(View.GONE);
//                image_accept_b.setVisibility(View.VISIBLE);
//                isAdviceSuccess=true;
//                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), image_accept_b);
//
//                advice_ima[0] = acceptiamgedata.getAdjunct_id();
//                advice_ima[1] = acceptiamgedata.getSys_file_name();
//                advice_ima[2] = "23";//adjunct_type : 据上传图片定
//                advice_ima[3] = acceptiamgedata.getFile_type();
//                advice_ima[4] = acceptiamgedata.getFile_size();
//                advice_ima[5] = "验收意见";//file_des:据上传图片定 身份证正面\大门照
//                advice_ima[6] = acceptiamgedata.getUser_file_name();
//                advice_ima[7] = acceptiamgedata.getPicmd5code();
//
//                record_list.add(acceptiamgedata);
//                break;
            default:

                break;
        }

    }


    /**
     * 加载验收详情数据请求
     */
    private class AcceptDetialRequest extends Request {

        @Override
        public void success(String jsonStr) {
            super.success(jsonStr);
            LogUtils.i("验收详情", jsonStr);

            //处理修改的数据
            acceptDetialentity = GsonTools.changeGsonToBean(jsonStr, AcceptDetialEntity.class);
            if (acceptDetialentity != null) {
                processModfiyData(acceptDetialentity);
               // getAcceptImageData(acceptDetialentity.getGaizao_id());
                //获取改造图片
                getAcceptImageDataGaiZao(acceptDetialentity.getGaizao_id());
                //获取重建图片
                if("1".equals(acceptDetialentity.getChongjian())){
                    getAcceptImageDataGaiZao(acceptDetialentity.getChongjian_id());
                }

            }
            //cancelLoadingDialog();
        }

        @Override
        public void error(String error) {
            super.error(error);
            LogUtils.i("验收详情", "error:" + error);
            cancelLoadingDialog();
        }
    }

    /**
     * 处理显示数据
     *
     * @param acceptDetialentity
     */
    private void processModfiyData(AcceptDetialEntity acceptDetialentity) {

        qrbparams.put("chongjian",acceptDetialentity.getChongjian());
        qrbparams.put("yanshou_opt",acceptDetialentity.getYanshou_opt());
        qrbparams.put("yanshou_opt_n",acceptDetialentity.getYanshou_opt_n());
        qrbparams.put("yanshou_result_n",acceptDetialentity.getYanshou_result_n());
        qrbparams.put("old_yanshou_result",acceptDetialentity.getYanshou_result_n());
        qrbparams.put("chongjian",acceptDetialentity.getChongjian());
        qrbparams.put("chongjian_id",acceptDetialentity.getChongjian_id());
        qrbparams.put("gaizao_id",acceptDetialentity.getGaizao_id());
        qrbparams.put("shgd_id_cj",acceptDetialentity.getShgd_id_cj());
        qrbparams.put("gaizao_type_cj",acceptDetialentity.getGaizao_type_cj());
        qrbparams.put("upt_time",acceptDetialentity.getNow());
        qrbparams.put("hfc_material_cj",acceptDetialentity.getHfc_material_cj());
        qrbparams.put("update_count",acceptDetialentity.getUpdate_count());

        String update_count = acceptDetialentity.getUpdate_count();
        int upCount = Integer.parseInt(update_count);
        if(upCount>=3){
            bt_save.setEnabled(false);
            bt_save.setClickable(false);
            bt_save.setBackgroundResource(R.drawable.toilet_sliding_tv_unselected);
        }



        accept_user_name.setText(acceptDetialentity.getArea_name());
        LogUtils.i("未改造测试", "processModfiyData: " + acceptDetialentity.getArea_name());
        accept_user_address.setText(acceptDetialentity.getMenpaihao());
        accept_user_pcode.setText(acceptDetialentity.getHuming());
        accept_user_tell.setText(acceptDetialentity.getHubianhao());
        accept_user_tellD.setText(acceptDetialentity.getCert_no());
        accept_user_IDLE.setText(acceptDetialentity.getXianzhi_n());
        accept_user_state.setText(acceptDetialentity.getGaizao_state_n());
        accept_user_type.setText(acceptDetialentity.getGaizao_type_n());
        accept_buildstyle.setText(acceptDetialentity.getGaizao_fangshi_n());

        accept_detuser_year.setText(acceptDetialentity.getStat_year_n());

        accept_user_shigongteam.setText(acceptDetialentity.getShgd_name());
        accept_user_huafenchi.setText(acceptDetialentity.getHfc_material_n());

        acceptRenkouTrascode.setText(acceptDetialentity.getRenkou());
        acceptTelTrascode.setText(acceptDetialentity.getPhone());

        accept_bianchi.setText(acceptDetialentity.getBianchi_n());
        accept_chongshui.setText(acceptDetialentity.getChongshuifangshi_n());
        accept_cefang.setText(acceptDetialentity.getCefang_n());

        if (!TextUtils.isEmpty(acceptDetialentity.getYanshou_result()) || !TextUtils.isEmpty(acceptDetialentity.getYanshou_result_n())) {

            if(!"-1".equals(acceptDetialentity.getYanshou_result())){
                tv_pull_choice.setText(acceptDetialentity.getYanshou_result_n());
                qrbparams.put("yanshou_result", acceptDetialentity.getYanshou_result());

                if(!TextUtils.isEmpty(acceptDetialentity.getYanshou_result())){
                    SPUtil.putString(Constants.OLD_YANSHOE_STATE,acceptDetialentity.getYanshou_result());
                }

                qrbparams.put("yanshou_result_n",acceptDetialentity.getYanshou_result_n());

                tv_pull_choice.setEnabled(false);
                //2019-09-04 不通过原因设置为合格时也可以查看
//                if("1".equals(acceptDetialentity.getYanshou_result())){
//                    all_accept_det_unfail.setVisibility(View.GONE);
//                    view_a.setVisibility(View.GONE);
//                }else{
//                    all_accept_det_unfail.setVisibility(View.VISIBLE);
//                    view_a.setVisibility(View.VISIBLE);
//                }
            }else{
                SPUtil.putString(Constants.OLD_YANSHOE_STATE,acceptDetialentity.getYanshou_result());
            }

        }

         //2019-09-04 将验收提示语改为请上传验收员到达现场和厕房位置的图片
//        String gaizaoType = acceptDetialentity.getGaizao_type_n();
//        if ("三格式".equals(gaizaoType)) {
//            upimg_statue.setText("请上传《三格式厕所改造质量验收记录表》");
//        } else if ("单坑+集中".equals(gaizaoType) || "水冲式".equals(gaizaoType)) {
//        }
            upimg_statue.setText("请上传验收员到达现场和厕房位置的图片");


        //重建信息
        String chongjian_type = acceptDetialentity.getGaizao_type_n_cj();
        if (!TextUtils.isEmpty(chongjian_type)) {
            accept_rebuild_title.setVisibility(View.VISIBLE);
            rebuild_date.setText(acceptDetialentity.getChongjian_time_str());//chongjian_time_str
            rebuild_buildtype.setText(acceptDetialentity.getGaizao_type_n_cj());
            rebuild_sgd.setText(acceptDetialentity.getShgd_name_cj());
        } else {
            accept_rebuild_title.setVisibility(View.GONE);
        }



        //问题5.5
//        String bili = acceptDetialentity.getBili();
//        if ("1".equals(bili) | "是".equals(bili)) {
//            rg_question_five_half.check(R.id.accept_detrb_five_half_pass);
//            qrbparams.put("bili", "1");
//        } else if ("0".equals(bili) | "否".equals(bili)) {
//            rg_question_five_half.check(R.id.accept_detrb_five_half_fail);
//            qrbparams.put("bili", "0");
//        }
//
//
//        //问题六    rb_two_pass.setChecked(true);rg_question_one.check(R.id.accept_detrb_one_pass);
//        String fuhe_rongji = acceptDetialentity.getRongjifuhe();
//        LogUtils.i("是否存在厕房", "问题六: " + fuhe_rongji);
//        if ("1".equals(fuhe_rongji) | "是".equals(fuhe_rongji)) {
//            rg_question_six.check(R.id.accept_detrb_six_pass);
//            qrbparams.put("rongjifuhe", "1");
//        } else if ("0".equals(fuhe_rongji) | "否".equals(fuhe_rongji)) {
//            rg_question_six.check(R.id.accept_detrb_six_fail);
//            qrbparams.put("rongjifuhe", "0");
//        }
//
//        //问题七
//
//        String fuhe_shendu = acceptDetialentity.getShenduhege();
//        LogUtils.i("是否存在厕房", "问题七: " + fuhe_shendu);
//        if ("1".equals(fuhe_shendu) | "是".equals(fuhe_shendu)) {
//            rg_question_seven.check(R.id.accept_detrb_seven_pass);
//            qrbparams.put("shenduhege", "1");
//        } else if ("0".equals(fuhe_shendu) | "否".equals(fuhe_shendu)) {
//            rg_question_seven.check(R.id.accept_detrb_seven_fail);
//            qrbparams.put("shenduhege", "0");
//        }
//        //问题八guandaoguifan
//
//        String gandao_guifan = acceptDetialentity.getGuandaoguifan();
//        LogUtils.i("是否存在厕房", "问题八: " + gandao_guifan);
//        if ("1".equals(gandao_guifan) | "是".equals(gandao_guifan)) {
//            rg_question_eight.check(R.id.accept_detrb_eight_pass);
//            qrbparams.put("guandaoguifan", "1");
//        } else if ("0".equals(gandao_guifan) | "否".equals(gandao_guifan)) {
//            rg_question_eight.check(R.id.accept_detrb_eight_fail);
//            qrbparams.put("guandaoguifan", "0");
//        }
//        //问题九fengeshenshui
//        String isShenshui = acceptDetialentity.getFengeshenshui();
//        LogUtils.i("是否存在厕房", "问题九: " + isShenshui);
//        if ("1".equals(isShenshui) | "是".equals(isShenshui)) {
//            rg_question_nine.check(R.id.accept_detrb_nine_pass);
//            qrbparams.put("fengeshenshui", "1");
//        } else if ("0".equals(isShenshui) | "否".equals(isShenshui)) {
//            rg_question_nine.check(R.id.accept_detrb_nine_fail);
//            qrbparams.put("fengeshenshui", "0");
//        }
//        //问题十
//
//        String guanchakou = acceptDetialentity.getLiuguanchakou();
//        LogUtils.i("是否存在厕房", "问题十: " + guanchakou);
//        if ("1".equals(guanchakou) | "是".equals(guanchakou)) {
//            rg_question_ten.check(R.id.accept_detrb_ten_pass);
//            qrbparams.put("liuguanchakou", "1");
//        } else if ("0".equals(guanchakou) | "否".equals(guanchakou)) {
//            rg_question_ten.check(R.id.accept_detrb_ten_fail);
//            qrbparams.put("liuguanchakou", "0");
//        }
//        //问题十一
//
//        String cailiaofuhe = acceptDetialentity.getCailiaofuhe();
//        LogUtils.i("是否存在厕房", "问题十一: " + cailiaofuhe);
//        if ("1".equals(cailiaofuhe) | "是".equals(cailiaofuhe)) {
//            rg_question_eleven.check(R.id.accept_detrb_eleven_pass);
//            qrbparams.put("cailiaofuhe", "1");
//        } else if ("0".equals(cailiaofuhe) | "否".equals(cailiaofuhe)) {
//            rg_question_eleven.check(R.id.accept_detrb_eleven_fail);
//            qrbparams.put("cailiaofuhe", "0");
//        }
//        //问题十二
//
//        String cafang_you = acceptDetialentity.getYoucefang();
//        LogUtils.i("是否存在厕房", "问题十二: " + cafang_you);
//        if ("1".equals(cafang_you) | "是".equals(cafang_you)) {
//            rg_question_twelve.check(R.id.accept_detrb_twelve_pass);
//            qrbparams.put("youcefang", "1");
//        } else if ("0".equals(cafang_you) | "否".equals(cafang_you)) {
//            rg_question_twelve.check(R.id.accept_detrb_twelve_fail);
//            qrbparams.put("youcefang", "0");
//        }
//        //问题十三
//
//        String ding_you = acceptDetialentity.getYouding();
//        LogUtils.i("是否存在厕房", "问题十三: " + ding_you);
//        if ("1".equals(ding_you) | "是".equals(ding_you)) {
//            rg_question_thirdteen.check(R.id.accept_detrb_thirdteen_pass);
//            qrbparams.put("youding", "1");
//        } else if ("0".equals(ding_you) | "否".equals(ding_you)) {
//            rg_question_thirdteen.check(R.id.accept_detrb_thirdteen_fail);
//            qrbparams.put("youding", "0");
//        }
//        //问题十四
//
//        String men_you = acceptDetialentity.getYoumen();
//        LogUtils.i("是否存在厕房", "问题十四: " + men_you);
//        if ("1".equals(men_you) | "是".equals(men_you)) {
//            rg_question_fourteen.check(R.id.accept_detrb_fouthteen_pass);
//            qrbparams.put("youmen", "1");
//        } else if ("0".equals(men_you) | "否".equals(men_you)) {
//            rg_question_fourteen.check(R.id.accept_detrb_fouthteen_fail);
//            qrbparams.put("youmen", "0");
//        }
//        //问题十五
//
//        String ying_fang = acceptDetialentity.getFangying();
//        LogUtils.i("是否存在厕房", "问题十五: " + ying_fang);
//        if ("1".equals(ying_fang) | "是".equals(ying_fang)) {
//            rg_question_fifteen.check(R.id.accept_detrb_fifteen_pass);
//            qrbparams.put("fangying", "1");
//        } else if ("0".equals(ying_fang) | "否".equals(ying_fang)) {
//            rg_question_fifteen.check(R.id.accept_detrb_fifteen_fail);
//            qrbparams.put("fangying", "0");
//        }
//        //问题十六
//
//        String dong_fang = acceptDetialentity.getFangdong();
//        LogUtils.i("是否存在厕房", "问题十六: " + dong_fang);
//        if ("1".equals(dong_fang) | "是".equals(dong_fang)) {
//            rg_question_sixteen.check(R.id.accept_detrb_sixteen_pass);
//            qrbparams.put("fangdong", "1");
//        } else if ("0".equals(dong_fang) | "否".equals(dong_fang)) {
//            rg_question_sixteen.check(R.id.accept_detrb_sixteen_fail);
//            qrbparams.put("fangdong", "0");
//        }
//        //问题十七
//
//        String chou_fang = acceptDetialentity.getFangchou();
//        LogUtils.i("是否存在厕房", "问题十七: " + chou_fang);
//        if ("1".equals(chou_fang) | "是".equals(chou_fang)) {
//            rg_question_seventeen.check(R.id.accept_detrb_seventeen_pass);
//            qrbparams.put("fangchou", "1");
//        } else if ("0".equals(chou_fang) | "否".equals(chou_fang)) {
//            rg_question_seventeen.check(R.id.accept_detrb_seventeen_fail);
//            qrbparams.put("fangchou", "0");
//        }


        //验收结果


        String yanshou_result_n = acceptDetialentity.getYanshou_result_n();
        if (!"未验收".equals(yanshou_result_n)) {


            LogUtils.i("是否存在厕房", "验收结果: " + yanshou_result_n);
            if (!TextUtils.isEmpty(yanshou_result_n)) {
                tv_pull_choice.setText(yanshou_result_n);

                qrbparams.put("yanshou_result", acceptDetialentity.getYanshou_result());
                qrbparams.put("yanshou_result_n", yanshou_result_n);

            }

            //验收人
            String yanshou_opt_n = acceptDetialentity.getYanshou_opt_n();
            LogUtils.i("是否存在厕房", "验收人: " + yanshou_opt_n);
            if (!TextUtils.isEmpty(yanshou_opt_n)) {

                //qrbparams.put("yanshou_opt", yanshou_opt_n);
                yanshou_opt_n=yanshou_opt_n.replace("[","");
                yanshou_opt_n=yanshou_opt_n.replace("]","");
                tv_acceptance.setText(yanshou_opt_n);
                qrbparams.put("yanshou_opt_n", yanshou_opt_n);

            }
            String yanshou_opt = acceptDetialentity.getYanshou_opt();
            yanshou_opt=yanshou_opt.replace("[","");
            yanshou_opt=yanshou_opt.replace("]","");
            qrbparams.put("yanshou_opt", yanshou_opt);


            //验收日期
            String yanshou_time_str = acceptDetialentity.getYanshou_time_str();
            LogUtils.i("是否存在厕房", "验收日期: " + yanshou_time_str);
            if (!TextUtils.isEmpty(yanshou_time_str)) {
                tv_date_pickter.setText(yanshou_time_str);
                //添加验收时间
                qrbparams.put("accept_date", yanshou_time_str);
            }


            //2017-09-04不通过原因可以为空
            String yanshou_remark = acceptDetialentity.getYanshou_remark();
            LogUtils.i("是否存在厕房", "不通过原因: " + yanshou_remark);
//            if (!TextUtils.isEmpty(yanshou_remark)) {
//                et_filereason.setText(yanshou_remark);
//                qrbparams.put("yanshou_remark", yanshou_remark);
//            }
            et_filereason.setText(yanshou_remark);
            qrbparams.put("yanshou_remark", yanshou_remark);

        }


    }

    private boolean isExBuyView = false;
    private boolean isBuildView = false;

    /**
     * View的各种点击监听
     *
     * @param view
     */
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            //点击个人信息,对应的展示
            case R.id.accept_detuser_title:
                //默认是关闭
//                if (!isExBuyView) {
//                    Util.openView(accept_user_showbody);//展开
//                    Util.openImageView(accept_detuser_iv_arrow);
//                    isExBuyView = true;
//                } else { //关闭
//                    Util.clossView(accept_user_showbody);
//                    Util.closeImageView(accept_detuser_iv_arrow);
//                    isExBuyView = false;
//                }

                //默认是展开
                if (!isExBuyView) {

                    Util.clossView(accept_user_showbody);
                    Util.closeImageViewFan(accept_detuser_iv_arrow);
                    isExBuyView = true;
                } else { //展开
                    Util.openView(accept_user_showbody);//展开
                    Util.openImageViewFan(accept_detuser_iv_arrow);

                    isExBuyView = false;
                }
                break;

            //点击重建信息
            case R.id.accept_rebuild_iner_title:
                //默认是关闭
                if (!isBuildView) {
                    Util.openView(accept_rebuild_body);//展开
                    Util.openImageView(accept_rebuild_arrow);
                    isBuildView = true;
                } else { //关闭
                    Util.clossView(accept_rebuild_body);
                    Util.closeImageView(accept_rebuild_arrow);
                    isBuildView = false;
                }


                break;
            //验收结果
            case R.id.accept_det_tv_pull_choices:
                accept_resaultlist.clear();

                accept_resaultlist.add("合格");
                accept_resaultlist.add("不合格");

                accept_resault_popupWindow = new ListPopupWindow(_mActivity);
                setPopuData(view, accept_resault_popupWindow, accept_resaultlist);
                setPopuClickListener(new PopuClickListener() {
                    @Override
                    public void show(String mess) {
                        //Toast.makeText(_mActivity, "验收结果是: " + mess, Toast.LENGTH_SHORT).show();
                        tv_pull_choice.setText(mess);
                        //提交时添加验收结果
                        //qrbparams.put("accept_resault", mess);
                        //2019-09-04 将不通过原因设置与验收结果无关联
//                        switch (mess) {
//                            case "合格":
//
//                                et_filereason.setHint("");
//                                et_filereason.setText("");
//                                et_filereason.setEnabled(false);
//
//                                break;
//                            case "不合格":
//                                et_filereason.setEnabled(true);
//                                et_filereason.setHint("请输入原因,文字个数小于100");
//                                break;
//
//                            default:
//
//                                break;
//                        }

                    }
                });

                break;
            //验收人
            case R.id.accept_det_tv_acceptance:

                showAlertDialog(_mActivity,"提示","修改验收人会清除原有验收人数据，确认更改吗？",new DialogClick(){
                    @Override
                    public void PositiveMessage() {
                        super.PositiveMessage();
                        if (acceptdatabean != null) {
                            Intent intent = new Intent(_mActivity, AccepterActivity.class);
                            //这个id貌似没用
                            intent.putExtra(Constants.YANSHOUREN, "验收");
                            startActivityForResult(intent, REQUEST_CODE_SELECT);
                        }
                    }

                    @Override
                    public void NegativeMessage() {
                        super.NegativeMessage();
                    }
                });




                break;
            //验收日期
            case R.id.accept_det_tv_date:
                TimePickerView.Type type = TimePickerView.Type.YEAR_MONTH_DAY;
                pvTime = new TimePickerView(_mActivity, type);
                String format = "yyyy-MM-dd";
                UtilPop.alertTimerPickerEh(getActivity(), pvTime, format, new UtilPop.TimerPickerCallBack() {
                    @Override
                    public void onTimeSelect(String date) {
                        //String nowTime = getNowTime();
                        String nowTime = netTime;
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        TimeUtils.getIntervalTime2(date, nowTime, ConstUtils.TimeUnit.DAY, sdf);
                        if (TimeUtils.getTypeValue() == 1) {
                            //showShortToast("选择时间不能晚于当前时间");
                            if (date.equals(getNowTime())) {
                                if (!getNowTime().equals(netTime)) {
                                    showAlertOnlyPos(_mActivity, "验收日期", "该日期不能晚于今天" + netTime);
                                }
                            }else{
                                //showShortToast("选择时间不能晚于当前时间");
                                showAlertOnlyPos(_mActivity, "验收日期", "选择时间不能晚于当前时间"+netTime);
                            }
                        } else {

                            if (date.equals(getNowTime())) {
                                if (!getNowTime().equals(netTime)) {
                                    showAlertOnlyPos(_mActivity, "验收日期", "该日期不能晚于今天" + netTime);
                                }else{
                                    tv_date_pickter.setText(date);
                                }
                            }else{
                                tv_date_pickter.setText(date);
                            }
                            //　选择时间　正确
                            //tv_date_pickter.setText(date);

                            //添加验收时间
                            //qrbparams.put("accept_date", date);
                        }
                    }
                });
                break;

            case R.id.accept_det_bt_save:

                boolean checkParams = getCheckParams();
                if (checkParams) {

                    //至此参数添加完成,上传参数上传完成后恢复为默认状态
                    // syso(qrbparams);
                    showLoadingDialog();

                    SaveUpData();
                }

                break;

            case R.id.imaga:

                GotoImageFg(accept_image_a, "11");//"身份证正面","身份证"

                break;
            case R.id.imagb:

                GotoImageFg(accept_image_b, "12");//大门照

                break;
            case R.id.imagc:

                GotoImageFg(accept_image_c, "13");//改造前

                break;
            case R.id.imagd:

                GotoImageFg(accept_image_d, "1401");//改造中

                break;
            case R.id.image:

                GotoImageFg(accept_image_e, "15");//改造后

                break;
            case R.id.imag_acceptdetail_gaizaotwo:

                GotoImageFg(imag_acceptdetail_gaizaotwo, "1402");//改造中2

                break;
            case R.id.imag_acceptdetail_gaizaothree:

                GotoImageFg(imag_acceptdetail_gaizaothree, "1403");//改造中3

                break;
            case R.id.accept_rebuild_iner_ing:

                GotoImageFgRebuild(rebuild_image_ing, "16");//重建中

                break;
            case R.id.accept_rebuild_iner_after:

                GotoImageFgRebuild(rebuild_image_after, "17");//重建后

                break;

            case R.id.up_accept_rl_a:
//                if(image_accept_a.getVisibility()==View.VISIBLE&&qrbparams.get("yanshou_result")!=null&&"1".equals(qrbparams.get("yanshou_result"))){
//                    GotoImageFgRecorelist(image_accept_a, "验收记录表");
//                }else{
//
//                }
                if("302".equals(optLevel)||"301".equals(optLevel)){
                    GotoImageFgRecorelist(image_accept_a, "验收记录表");
                }else{
                    mLayoutType = 4;
                    showPhotoPic();
                }




                break;
            case R.id.up_accept_rl_b:

//                if(image_accept_b.getVisibility()==View.VISIBLE&&qrbparams.get("yanshou_result")!=null&&"1".equals(qrbparams.get("yanshou_result"))){
//                    GotoImageFgRecorelist(image_accept_b, "验收意见");
//                }else{
//
//                }

                if("302".equals(optLevel)||"301".equals(optLevel)){
                    GotoImageFgRecorelist(image_accept_b, "验收意见");
                }else{
                    mLayoutType = 5;
                    showPhotoPic();
                }




                break;
                //2019-09-04 17:59
            case R.id.up_accept_xiang:

                if("302".equals(optLevel)||"301".equals(optLevel)){
                    GotoImageFgRecorelist(image_accept_xiang, "乡现场验收");
                }else{
                    mLayoutType = 6;
                    showPhotoPic();
                }
                break;
            case R.id.up_accept_xian:

                if("302".equals(optLevel)||"301".equals(optLevel)){
                    GotoImageFgRecorelist(image_accept_xian, "县现场验收");
                }else{
                    mLayoutType = 7;
                    showPhotoPic();
                }
                break;
            case R.id.up_accept_shi:

                if("302".equals(optLevel)||"301".equals(optLevel)){
                    GotoImageFgRecorelist(image_accept_shi, "市现场验收");
                }else{
                    mLayoutType = 8;
                    showPhotoPic();
                }
                break;

            default:

                break;
        }
    }

    private int mLayoutType = -1;

    private void showPhotoPic() {
        String carrier = android.os.Build.MANUFACTURER;
        LogUtils.i("手机厂商", "showPhotoPic: " + carrier);
        showPhotoPicker();
    }

    private void showPhotoPicker() {
        PhotoPicker.builder()
                .setPhotoCount(1) //显示图片张
                .setPreviewEnabled(false)
                .start(_mActivity, this, PhotoPicker.REQUEST_CODE);
    }

    /**
     * 跳转到验收人页面
     *
     * @param imageview
     * @param contextValue
     */
    private void GotoImageFg(ImageView imageview, String contextValue) {

        if (imageview.getVisibility() == View.VISIBLE && acceptImageEntitiesGaizao != null
                && acceptImageEntitiesGaizao.size() > 0) {
            for (AcceptImageEntity acceptiamgedata : acceptImageEntitiesGaizao) {
                if (contextValue.equals(acceptiamgedata.getAdjunct_type())) {
                    EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));

                }
            }
        }

    }
    private void GotoImageFgRebuild(ImageView imageview, String contextValue) {

        if (imageview.getVisibility() == View.VISIBLE && acceptImageEntities != null
                && acceptImageEntities.size() > 0) {
            for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                if (contextValue.equals(acceptiamgedata.getAdjunct_type())) {
                    EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));

                }
            }
        }

    }

    private void GotoImageFgRecorelist(ImageView imageview, String contextValue) {

        if (imageview.getVisibility() == View.VISIBLE && record_list != null
                && record_list.size() > 0) {
            for (AcceptImageEntity acceptiamgedata : record_list) {
                if (contextValue.equals(acceptiamgedata.getFile_des())) {
                    EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));

                }
            }
        }

    }



    /**
     * 获取的提交数据
     */
    private void SaveUpData() {

        final String accept_up_save_url = HttpApis.acceptDetial_saveUp + acceptdatabean.getYanshou_id();

        LogUtils.i("详情提交参数", "url: " + accept_up_save_url);

        qrbparams.put("idfield", "yanshou_id");

        //2019-09-04将不通过原因设置为不合格也可以提交成功
//        String check_resault = tv_pull_choice.getText().toString().trim();
//        if ("不合格".equals(check_resault)) {
//            if (TextUtils.isEmpty(et_filereason.getText().toString().trim())) {
//                showAlertOnlyPos(_mActivity, "不通过原因", "请填写不通过原因");
//                cancelLoadingDialog();
//                return;
//            }
//        }

        qrbparams.put("buchongfu", getBuChongfuTime());

        qrbparams.put("adjunct_id",  recordlist_ima[0] + "," + advice_ima[0]+ "," + advice_ima_xiang[0]+ "," + advice_ima_xian[0]+ "," + advice_ima_shi[0] );
        qrbparams.put("sys_file_name", recordlist_ima[1] + "," + advice_ima[1]+ "," + advice_ima_xiang[1]+ "," + advice_ima_xian[1]+ "," + advice_ima_shi[1]);
        qrbparams.put("adjunct_type",  recordlist_ima[2] + "," + advice_ima[2]+ "," + advice_ima_xiang[2]+ "," + advice_ima_xian[2]+ "," + advice_ima_shi[2] );
        qrbparams.put("file_type",  recordlist_ima[3] + "," + advice_ima[3]+ "," + advice_ima_xiang[3]+ "," + advice_ima_xian[3]+ "," + advice_ima_shi[3]);
        qrbparams.put("file_size",  recordlist_ima[4] + "," + advice_ima[4]+ "," + advice_ima_xiang[4]+ "," + advice_ima_xian[4]+ "," + advice_ima_shi[4]);
        qrbparams.put("file_des",  recordlist_ima[5] + "," + advice_ima[5]+ "," + advice_ima_xiang[5]+ "," + advice_ima_xian[5]+ "," + advice_ima_shi[5]);
        qrbparams.put("user_file_name",  recordlist_ima[6] + "," + advice_ima[6]+ "," + advice_ima_xiang[6]+ "," + advice_ima_xian[6]+ "," + advice_ima_shi[6]);

        //设置记录表参数
//        apEntity.setAdjunct_id(new String[]{recordlist_ima[0], advice_ima[0]});
//        apEntity.setSys_file_name(new String[]{recordlist_ima[1], advice_ima[1]});
//        apEntity.setAdjunct_type(new String[]{recordlist_ima[2], advice_ima[2]});
//        apEntity.setFile_type(new String[]{recordlist_ima[3], advice_ima[3]});
//        apEntity.setFile_size(new String[]{recordlist_ima[4], advice_ima[4]});
//        apEntity.setFile_des(new String[]{recordlist_ima[5], advice_ima[5]});
//        apEntity.setUser_file_name(new String[]{recordlist_ima[6], advice_ima[6]});

//        accept_up_save_url=accept_up_save_url +"?idfield=yanshou_id"
//                +"&yanshou_result="+qrbparams.get("yanshou_result")
//                +"&yanshou_result_n="+qrbparams.get("yanshou_result_n")
//                +"&yanshou_time="+qrbparams.get("yanshou_time")
//                +"&yanshou_remark="+qrbparams.get("yanshou_remark")
//                +"&yanshou_opt_n="+qrbparams.get("yanshou_opt_n")
//                +"&yanshou_opt="+qrbparams.get("yanshou_opt")
//                +"&accept_date="+qrbparams.get("accept_date")
//                +"&buchongfu="+qrbparams.get("buchongfu")
//                +"&adjunct_id="+recordlist_ima[0]+"&adjunct_id="+advice_ima[0]
//                +"&sys_file_name="+recordlist_ima[1]+"&sys_file_name="+advice_ima[1]
//                +"&adjunct_type="+recordlist_ima[2]+"&adjunct_type="+advice_ima[2]
//                +"&file_type="+recordlist_ima[3]+"&file_type="+advice_ima[3]
//                +"&file_size="+recordlist_ima[4]+"&file_size="+advice_ima[4]
//                +"&file_des="+recordlist_ima[5]+"&file_des="+advice_ima[5]
//                +"&user_file_name="+recordlist_ima[6]+"&user_file_name="+advice_ima[6]
//
//        ;

        LogUtils.i("详情提交参数", "url: " + accept_up_save_url);


//0522使用
//        HttpUtils.requestPostUrl(_mActivity, accept_up_save_url, new Request() {
//            @Override
//            public void success(String jsonStr) {
//                super.success(jsonStr);
//                LogUtils.i("详情提交参数", "success: " + jsonStr);
//                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);
//
//                if (fileeditip != null && "success".equals(fileeditip.getState())) {
//                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();
//
//
//                    //提交完成后
//                    qrbparams.clear();
//
//
//                    tv_pull_choice.setText("下拉选择");
//                    et_filereason.setText("");
//
//                    tv_acceptance.setText("点击选择验收人");
//
//                    rg_question_one.clearCheck();
//                    rg_question_two.clearCheck();
//                    rg_question_three.clearCheck();
//                    rg_question_four.clearCheck();
//                    rg_question_five.clearCheck();
//
//
//                    EventBus.getDefault().post(new MessageEvent("360"));
//                    //保存成功后回到列表页
//                    _mActivity.onBackPressed();
//
//
//                }
//
//
//                cancelLoadingDialog();
//            }
//
//            @Override
//            public void error(String error) {
//                super.error(error);
//                LogUtils.i("详情提交参数", "error: " + error);
//                cancelLoadingDialog();
//            }
//        });


//--------------------------------------------------------
//        OkHttpUtils
//                .post()
//                .url(accept_up_save_url)
//                .addParams("idfield", "yanshou_id")
//                .addParams("yanshou_result", qrbparams.get("yanshou_result"))
//                .addParams("yanshou_result_n", qrbparams.get("yanshou_result_n"))
//                .addParams("yanshou_time", qrbparams.get("yanshou_time"))
//                .addParams("yanshou_remark", qrbparams.get("yanshou_remark"))
//                .addParams("yanshou_opt_n", qrbparams.get("yanshou_opt_n"))
//                .addParams("yanshou_opt", qrbparams.get("yanshou_opt"))
//                .addParams("accept_date", qrbparams.get("accept_date"))
//                .addParams("buchongfu", qrbparams.get("buchongfu"))
//                .addParams("adjunct_id", recordlist_ima[0])
//                .addParams("adjunct_id", advice_ima[0])
//                .addParams("sys_file_name", recordlist_ima[1])
//                .addParams("sys_file_name", advice_ima[1])
//                .addParams("adjunct_type", recordlist_ima[2])
//                .addParams("adjunct_type", advice_ima[2])
//                .addParams("file_type", recordlist_ima[3])
//                .addParams("file_type", advice_ima[3])
//                .addParams("file_size", recordlist_ima[4])
//                .addParams("file_size", advice_ima[4])
//                .addParams("file_des", recordlist_ima[5])
//                .addParams("file_des", advice_ima[5])
//                .addParams("user_file_name", recordlist_ima[6])
//                .addParams("user_file_name", advice_ima[6])
//                .build()
//                .execute(new StringCallback() {
//                    @Override
//                    public void onError(Call call, Exception e, int id) {
//
//                    }
//
//                    @Override
//                    public void onResponse(String response, int id) {
//
//                    }
//                });


        if(TextUtils.isEmpty((String)qrbparams.get("accept_date"))){
            qrbparams.put("accept_date" ,"");
        }

//        Map<String,String> map1 =new IdentityHashMap<String,String>(100);
//        map1.put(new String("idfield"), "yanshou_id");
//        map1.put(new String("yanshou_result"), qrbparams.get("yanshou_result"));
//        map1.put(new String("yanshou_result_n"), qrbparams.get("yanshou_result_n"));
//        map1.put(new String("yanshou_time"), qrbparams.get("yanshou_time"));
//        map1.put(new String("yanshou_remark"), qrbparams.get("yanshou_remark"));
//        map1.put(new String("yanshou_opt_n"), qrbparams.get("yanshou_opt_n"));
//        map1.put(new String("yanshou_opt"), qrbparams.get("yanshou_opt"));
//        map1.put(new String("accept_date"),  qrbparams.get("accept_date"));
//        map1.put(new String("buchongfu"),qrbparams.get("buchongfu"));
//        map1.put(new String("adjunct_id"), recordlist_ima[0]);
//        map1.put(new String("adjunct_id"), advice_ima[0]);
//        map1.put(new String("sys_file_name"), recordlist_ima[1]);
//        map1.put(new String("sys_file_name"), advice_ima[1]);
//        map1.put(new String("adjunct_type"), recordlist_ima[2]);
//        map1.put(new String("adjunct_type"), advice_ima[2]);
//        map1.put(new String("file_type"), recordlist_ima[3]);
//        map1.put(new String("file_type"),  advice_ima[3]);
//        map1.put(new String("file_size"), recordlist_ima[4]);
//        map1.put(new String("file_size"), advice_ima[4]);
//        map1.put(new String("file_des"), recordlist_ima[5]);
//        map1.put(new String("file_des"),advice_ima[5]);
//        map1.put(new String("user_file_name"), recordlist_ima[6]);
//        map1.put(new String("user_file_name"), advice_ima[6]);

        ArrayList<String>  adjunct_id=new ArrayList<>();
        adjunct_id.add(recordlist_ima[0]);
        adjunct_id.add(advice_ima[0]);

        adjunct_id.add(advice_ima_xiang[0]);
//        adjunct_id.add(advice_ima_xian[0]);
//        adjunct_id.add(advice_ima_shi[0]);

        ArrayList<String>  sys_file_name=new ArrayList<>();
        sys_file_name.add(recordlist_ima[1]);
        sys_file_name.add(advice_ima[1]);
        sys_file_name.add(advice_ima_xiang[1]);
//        sys_file_name.add(advice_ima_xian[1]);
//        sys_file_name.add(advice_ima_shi[1]);
        ArrayList<String>  adjunct_type=new ArrayList<>();
        adjunct_type.add(recordlist_ima[2]);
        adjunct_type.add(advice_ima[2]);
        adjunct_type.add(advice_ima_xiang[2]);
//        adjunct_type.add(advice_ima_xian[2]);
//        adjunct_type.add(advice_ima_shi[2]);

        ArrayList<String>  file_type=new ArrayList<>();
        file_type.add(recordlist_ima[3]);
        file_type.add(advice_ima[3]);
        file_type.add(advice_ima_xiang[3]);
//        file_type.add(advice_ima_xian[3]);
//        file_type.add(advice_ima_shi[3]);

        ArrayList<String>  file_size=new ArrayList<>();
        file_size.add(recordlist_ima[4]);
        file_size.add(advice_ima[4]);
        file_size.add(advice_ima_xiang[4]);
//        file_size.add(advice_ima_xian[4]);
//        file_size.add(advice_ima_shi[4]);

        ArrayList<String>  file_des=new ArrayList<>();
        file_des.add(recordlist_ima[5]);
        file_des.add(advice_ima[5]);
        file_des.add(advice_ima_xiang[5]);
//        file_des.add(advice_ima_xian[5]);
//        file_des.add(advice_ima_shi[5]);

        ArrayList<String>  user_file_name=new ArrayList<>();
        user_file_name.add(recordlist_ima[6]);
        user_file_name.add(advice_ima[6]);
        user_file_name.add(advice_ima_xiang[6]);
//        user_file_name.add(advice_ima_xian[6]);
//        user_file_name.add(advice_ima_shi[6]);

        ArrayList<String>  picmd5code=new ArrayList<>();
        picmd5code.add(recordlist_ima[7]);
        picmd5code.add(advice_ima[7]);
        picmd5code.add(advice_ima_xiang[7]);
//        picmd5code.add(advice_ima_xian[7]);
//        picmd5code.add(advice_ima_shi[7]);

        qrbparams.put("adjunct_id", adjunct_id);
        qrbparams.put("sys_file_name", sys_file_name);
        qrbparams.put("adjunct_type", adjunct_type);
        qrbparams.put("file_type", file_type);
        qrbparams.put("file_size", file_size);
        qrbparams.put("file_des", file_des);
        qrbparams.put("user_file_name", user_file_name);
        qrbparams.put("picmd5code", picmd5code);

        qrbparams.put("token",token_data);



        //0523
//        HttpUtils.requestPostYanShou1(_mActivity, accept_up_save_url,
//                qrbparams,advice_ima, new Request() {
//            @Override
//            public void success(String jsonStr) {
//                super.success(jsonStr);
//                LogUtils.i("详情提交参数", "success: " + jsonStr);
//                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);
//
//                if (fileeditip != null && "success".equals(fileeditip.getState())) {
//                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();
//
//
//                    //提交完成后
//                    qrbparams.clear();
//
//
//                    tv_pull_choice.setText("下拉选择");
//                    et_filereason.setText("");
//
//                    tv_acceptance.setText("点击选择验收人");
//
//                    rg_question_one.clearCheck();
//                    rg_question_two.clearCheck();
//                    rg_question_three.clearCheck();
//                    rg_question_four.clearCheck();
//                    rg_question_five.clearCheck();
//
//
//                    EventBus.getDefault().post(new MessageEvent("360"));
//                    //保存成功后回到列表页
//                    _mActivity.onBackPressed();
//
//
//                }
//
//
//                cancelLoadingDialog();
//            }
//
//            @Override
//            public void error(String error) {
//                super.error(error);
//                LogUtils.i("详情提交参数", "error: " + error);
//                cancelLoadingDialog();
//            }
//        });




//--------------------------------------------------------
//最早使用
        HttpUtils.requestPostGson(_mActivity, accept_up_save_url, qrbparams, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.i("详情提交参数", "success: " + jsonStr);
                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);

                if (fileeditip != null && "success".equals(fileeditip.getState())) {
                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();
                    //提交完成后
                    qrbparams.clear();
                    tv_pull_choice.setText("下拉选择");
                    et_filereason.setText("");

                    tv_acceptance.setText("点击选择验收人");

                    rg_question_one.clearCheck();
                    rg_question_two.clearCheck();
                    rg_question_three.clearCheck();
                    rg_question_four.clearCheck();
                    rg_question_five.clearCheck();


                    EventBus.getDefault().post(new MessageEvent("360"));
                    //保存成功后回到列表页
                    _mActivity.onBackPressed();

                }
                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                LogUtils.i("详情提交参数", "error: " + error);
                cancelLoadingDialog();
            }
        });

    }



    private String getBuChongfuTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }

    /**
     * 提交数据前检查参数
     */
    private boolean getCheckParams() {
            //2019-09-05 需求改动，只设置为乡级现场验收为必传项
//        if (!isRecordlistSuccess || !isAdviceSuccess) {
//            showAlertOnlyPos(_mActivity, "照片", "请上传验收记录表和验收意见照片");
//            return false;
//        }
        if (!isXiangSuccess) {
            showAlertOnlyPos(_mActivity, "照片", "请上传乡现场验收照片");
            return false;
        }


        //检查验收结果
        String accept_result = tv_pull_choice.getText().toString().trim();
        if (TextUtils.isEmpty(accept_result) || "下拉选择".equals(accept_result)) {
            showAlertOnlyPos(_mActivity, "验收结果", "请选择验收结果");
            return false;
        } else {
            switch (accept_result) {
                case "合格":
                    qrbparams.put("yanshou_result", "1");
                    qrbparams.put("yanshou_result_n", "合格");

                    break;
                case "不合格":
                    qrbparams.put("yanshou_result", "0");
                    qrbparams.put("yanshou_result_n", "不合格");

                    break;

                default:

                    break;
            }

            String old_statue_ = SPUtil.getString(Constants.OLD_YANSHOE_STATE, "");
            if(!TextUtils.isEmpty(old_statue_)){//old_yanshou_result
                qrbparams.put("old_yanshou_result", old_statue_);
            }
        }




        //检查不通过原因
        String et_reason = et_filereason.getText().toString().trim();
        if("不合格".equals(accept_result)){
            if(TextUtils.isEmpty(et_reason)){
                showAlertOnlyPos(_mActivity, "备注", "请输入不合格原因");
                return false;
            }else if(!TextUtils.isEmpty(et_reason)&&et_reason.length()>100){
                showAlertOnlyPos(_mActivity, "备注", "内容超过100个字符");
                return false;
            }
        }

        qrbparams.put("yanshou_remark", et_reason);//yanshou_remark


        //检查验收人
        String acceptance = tv_acceptance.getText().toString().trim();
        if (TextUtils.isEmpty(acceptance) || "点击选择验收人".equals(acceptance)||"[]".equals(acceptance)) {
            showAlertOnlyPos(_mActivity, "验收人", "请选择验收人");
            return false;
        }

        //验收日期
        String date_pick = tv_date_pickter.getText().toString().trim();
        if ("点击选择时间".equals(date_pick)||TextUtils.isEmpty(date_pick)) {
            showAlertOnlyPos(_mActivity, "验收日期", "请确认验收日期");
            return false;
        } else {
            qrbparams.put("yanshou_time", date_pick);
            return true;
        }



    }

    //请求码
    public static final int REQUEST_CODE_SELECT = 100;

    private String sbaccepterValue = "[";
    private String sbaccepterId = "[";

    /**
     * 页面回调
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            //添加图片返回
            if (data != null && requestCode == REQUEST_CODE_SELECT) {

                Bundle bundle = data.getBundleExtra("inters");
                List<AcceptanceEntity> ava = (List<AcceptanceEntity>) bundle.getSerializable("bundle");
                for (int i = 0; i < ava.size(); i++) {
                    if (i != ava.size() - 1) {
                        sbaccepterValue = sbaccepterValue + ava.get(i).getText() + ",";
                        sbaccepterId = sbaccepterId + ava.get(i).getValue() + ",";
                    } else {
                        sbaccepterValue = sbaccepterValue + ava.get(i).getText();
                        sbaccepterId = sbaccepterId + ava.get(i).getValue();
                    }

                }

                sbaccepterValue = sbaccepterValue + ("]");
                sbaccepterId = sbaccepterId + ("]");


                LogUtils.i("获得验收人", "onActivityResult: " + sbaccepterValue.toString());
                LogUtils.i("获得验收人", "onActivityResult: " + sbaccepterId.toString());
                String opt=sbaccepterId.toString();
                String opt_n=sbaccepterValue.toString();
                opt=opt.replace("]","");
                opt=opt.replace("[","");
                opt_n=opt_n.replace("]","");
                opt_n=opt_n.replace("[","");
                tv_acceptance.setText(opt_n);
                qrbparams.put("yanshou_opt_n", opt_n);
                qrbparams.put("yanshou_opt", opt);


                ava.clear();
                sbaccepterValue = "[";
                sbaccepterId = "[";


            } else if (resultCode == RESULT_OK && requestCode == PhotoPicker.REQUEST_CODE && data != null) {
                ArrayList<String> photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);

                //=========添加水印=========
                String absolutePath = photos.get(0);

                if(absolutePath.endsWith(":abc")){
                    absolutePath=absolutePath.substring(0,absolutePath.length()-4);
                    savePic(absolutePath);
                }


                //==========添加水印========

                showLoadingDialog("正在上传图片");
                for (int i = 0; i < photos.size(); i++) {
                    String uri = Uri.decode(photos.get(i));
                    if(uri.endsWith(":abc")){
                        uri=uri.substring(0,uri.length()-4);
                    }
                    LogUtils.e("uri", uri);
                    try {
                        compressWithRx(new File(uri));
                    } catch (Exception e) {
                        Toast.makeText(_mActivity, "请重新上传", Toast.LENGTH_SHORT).show();

                    }
                }

            }
        }
    }

    private void savePic(String filename) {

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPurgeable = true;
        options.inSampleSize = 2;
        Bitmap bm= BitmapFactory.decodeFile(filename,options);


        File file = new File(filename);

        // stringToBitmap(file.getAbsolutePath());
        try {
            FileOutputStream fos = new FileOutputStream(file);
//			FileInputStream fis = new FileInputStream(new File(tempPicPath)) ;
            byte[] temp = new byte[1024];
            //添加时间水印
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            String time = sdf.format(new Date(System.currentTimeMillis()));


//            URL url = new URL("http://110.249.173.26:8081");
//            //url = new URL("http://www.baidu.com");
//            //url = new URL("http://www.ntsc.ac.cn");//中国科学院国家授时中心
//            //url = new URL("http://www.bjtime.cn");
//            URLConnection uc = url.openConnection();//生成连接对象
//            uc.connect(); //发出连接
//            long ld = uc.getDate(); //取得网站日期时间
//            Calendar calendar = Calendar.getInstance();
//            calendar.setTimeInMillis(ld);
//            int i = calendar.get(Calendar.YEAR);
//            int j = calendar.get(Calendar.MONTH);
//            j=j+1;
//            int x = calendar.get(Calendar.DAY_OF_MONTH);

            String time =netTime;


            String address = MyApplication.getAddress();
            if(address==null){
                address="";
            }

            Bitmap newbm = ImageUtils.drawTextToRightBottom(_mActivity, bm, time+";"+address,
                    25, ContextCompat.getColor(_mActivity,R.color.show2), 10, 10);


            //Bitmap newbmOne = addTimeFlag(_mActivity,newbm);
            newbm.compress(Bitmap.CompressFormat.JPEG, 100, fos);// 把数据写入文件
            fos.flush();
            fos.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    private void compressWithRx(File file) {

        Flowable.just(file)
                .observeOn(Schedulers.io())
                .map(new Function<File, File>() {
                    @Override
                    public File apply(@NonNull File file) {//  throws Exception
                        try {
                            File file1 = Luban.with(_mActivity).load(file).get();
                            return file1;
                        } catch (Exception e) {
                            //对于文件损坏的文件/压缩失败的文件,也能上传,但是,在主线程中提示
                            //记住,修改权限
                            _mActivity.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    showShortToast("请重新上传");
                                }
                            });

                            return file;
                        }

                    }
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<File>() {
                    @Override
                    public void accept(@NonNull File file) {
                        LogUtils.e("fileinfo", "file- " + file.length() / 1024 + "k" + " name- " + file.getName() + " paht- " + file.getPath());
                        //上传图片
                        if (file == null) {
                            Toast.makeText(_mActivity, "请重新上传", Toast.LENGTH_SHORT).show();
                        } else {
                            uploadImgFile(file, file.getName(), file.getPath());
                        }

                    }


                });
    }

    private boolean isUploadSuccess;

    private void uploadImgFile(final File file, final String fileName, final String filepath) {
        String url = HttpApis.upload_image;
        HashMap<String, String> map = new HashMap<>();
        map.put("token",token_data);
        HttpUtils.requestPostFileMapUploades(getActivity(), url, fileName, file,map, new Request() {

            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.e("上传图片成功detial", "jsonSuccess  " + jsonStr);
                UploadImageEntity uploadImageEntity = GsonTools.changeGsonToBean(jsonStr, UploadImageEntity.class);
                if ("SUCCESS".equals(uploadImageEntity.getState())) {

                    if("0".equals(uploadImageEntity.getIsrepeat())){
                        isUploadSuccess = true;
                        displayUploadImgFile(uploadImageEntity, fileName);  //将img显示
                    }else{
                        showAlertOnlyPos(_mActivity,"图片上传","图片上传重复,请重新上传");
                        isUploadSuccess = false;
                    }


                } else {
                    //showShortToast("上传失败，图片大小不能超过4兆");
                    showAlertOnlyPos(_mActivity,"图片上传","上传失败，图片大小不能超过4兆");
                    isUploadSuccess = false;
                }
                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                isUploadSuccess = false;
                cancelLoadingDialog();
            }
        });

    }

    private String[] recordlist_ima = new String[]{null, null, null, null, null, null, null, null};
    private String[] advice_ima = new String[]{null, null, null, null, null, null, null, null};
    private String[] advice_ima_xiang = new String[]{null, null, null, null, null, null, null, null};
    private String[] advice_ima_xian = new String[]{null, null, null, null, null, null, null, null};
    private String[] advice_ima_shi = new String[]{null, null, null, null, null, null, null, null};
    private boolean isRecordlistSuccess;
    private boolean isAdviceSuccess;
    private boolean isXiangSuccess;
    private boolean isXianSuccess;
    private boolean isShiSuccess;

    private void displayUploadImgFile(UploadImageEntity uploadImageEntity, String fileName) {

        qrbparams.put("adj_table_info","bill_adjunct$business_id");
        switch (mLayoutType) {
            case 4:

                sell_accept_one.setVisibility(View.GONE);
                image_accept_a.setVisibility(View.VISIBLE);
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath())
                        .into(image_accept_a);

                up_accept_rl_a.setBackgroundResource(R.color.status_translate);

                recordlist_ima[0] = uploadImageEntity.getFileID();
                recordlist_ima[1] = uploadImageEntity.getFilePath();
                recordlist_ima[2] = "22";//adjunct_type : 据上传图片定
                recordlist_ima[3] = uploadImageEntity.getFileExt();
                recordlist_ima[4] = uploadImageEntity.getSize();
                recordlist_ima[5] = "验收记录表";//file_des:据上传图片定 身份证正面\大门照
                recordlist_ima[6] = fileName;
                recordlist_ima[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isRecordlistSuccess = isUploadSuccess;
                }
                break;
            case 5:

                sell_accept_two.setVisibility(View.GONE);
                image_accept_b.setVisibility(View.VISIBLE);
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(image_accept_b);

                up_accept_rl_b.setBackgroundResource(R.color.status_translate);

                advice_ima[0] = uploadImageEntity.getFileID();
                advice_ima[1] = uploadImageEntity.getFilePath();
                advice_ima[2] = "23";//adjunct_type : 据上传图片定
                advice_ima[3] = uploadImageEntity.getFileExt();
                advice_ima[4] = uploadImageEntity.getSize();
                advice_ima[5] = "验收意见";//file_des:据上传图片定 身份证正面\大门照
                advice_ima[6] = fileName;
                advice_ima[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isAdviceSuccess = isUploadSuccess;
                }
                break;

            case 6:

                accept_myFile_three.setVisibility(View.GONE);
                image_accept_xiang.setVisibility(View.VISIBLE);
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(image_accept_xiang);

                up_accept_xiang.setBackgroundResource(R.color.status_translate);

                advice_ima_xiang[0] = uploadImageEntity.getFileID();
                advice_ima_xiang[1] = uploadImageEntity.getFilePath();
                advice_ima_xiang[2] = "31";//adjunct_type : 据上传图片定
                advice_ima_xiang[3] = uploadImageEntity.getFileExt();
                advice_ima_xiang[4] = uploadImageEntity.getSize();
                advice_ima_xiang[5] = "乡现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_xiang[6] = fileName;
                advice_ima_xiang[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isXiangSuccess = isUploadSuccess;
                }

                break;
            case 7:

                accept_myFile_four.setVisibility(View.GONE);
                image_accept_xian.setVisibility(View.VISIBLE);
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(image_accept_xian);

                up_accept_xian.setBackgroundResource(R.color.status_translate);

                advice_ima_xian[0] = uploadImageEntity.getFileID();
                advice_ima_xian[1] = uploadImageEntity.getFilePath();
                advice_ima_xian[2] = "32";//adjunct_type : 据上传图片定
                advice_ima_xian[3] = uploadImageEntity.getFileExt();
                advice_ima_xian[4] = uploadImageEntity.getSize();
                advice_ima_xian[5] = "县现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_xian[6] = fileName;
                advice_ima_xian[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isXianSuccess = isUploadSuccess;
                }

                break;
            case 8:
                accept_myFile_five.setVisibility(View.GONE);
                image_accept_shi.setVisibility(View.VISIBLE);
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(image_accept_shi);

                up_accept_shi.setBackgroundResource(R.color.status_translate);

                advice_ima_shi[0] = uploadImageEntity.getFileID();
                advice_ima_shi[1] = uploadImageEntity.getFilePath();
                advice_ima_shi[2] = "33";//adjunct_type : 据上传图片定
                advice_ima_shi[3] = uploadImageEntity.getFileExt();
                advice_ima_shi[4] = uploadImageEntity.getSize();
                advice_ima_shi[5] = "市现场验收";//file_des:据上传图片定 身份证正面\大门照
                advice_ima_shi[6] = fileName;
                advice_ima_shi[7] = uploadImageEntity.getPicmd5code();

                if (isUploadSuccess) {
                    isShiSuccess = isUploadSuccess;
                }

                break;

            default:
                break;

        }

    }

    /**
     * 得到当前时间
     */
    private String getNowTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }


    /**
     * 显示listpopuwindow,并使用回调,显示数据
     *
     * @param view
     * @param mPopupWindow
     * @param datalist
     */
    private void setPopuData(View view, final ListPopupWindow mPopupWindow, final List<String> datalist) {
        ArrayAdapter<String> adapter = new ArrayAdapter<>(_mActivity, android.R.layout.simple_list_item_1, datalist);
        mPopupWindow.setAdapter(adapter);

        //弹出的位置  弹出锚点
        mPopupWindow.setAnchorView(view);
        //设置宽高
        mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);

        mPopupWindow.setModal(true);//设置模态框，设置为true响应物理键
        //设置条目点击事件
        mPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //使用回调,显示数据
                if (popuClickListener != null) {
                    popuClickListener.show("" + datalist.get(position));
                }
                mPopupWindow.dismiss();
            }
        });
        mPopupWindow.show();
    }

    //-------------设置popu传值接口-----------------------------------------------------------
    public PopuClickListener popuClickListener;

    public void setPopuClickListener(PopuClickListener popuClickListener) {
        this.popuClickListener = popuClickListener;
    }

    /**
     * eventBus接受数据
     *
     * @param center
     */
    @Subscribe
    public void onEventThread(EventCenter center) {

        if (center.getEventCode() == EventConstant.ORG_SUPPLY_INFOR_INDEX) {


        }

    }


    @Override
    public void onPause() {
        super.onPause();
        if (pvTime != null && pvTime.isShowing()) {
            pvTime.dismiss();
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (pvTime != null && pvTime.isShowing()) {
            pvTime.dismiss();
            pvTime = null;
        }
        //这里要不要释放这个map集合资源
        if (qrbparams != null) {

        }
        EventBus.getDefault().unregister(this);
        OkHttpUtils.getInstance().cancelTag(this);
        cancelLoadingDialog();
        handler.removeCallbacksAndMessages(null);
    }
}
